import wepy from 'wepy'
import { api } from './configLawyer'
import { requestData } from './util'

//律师认证 填写认证信息
export const certificationLawyer = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.certificationLawyer.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.certificationLawyer.method,
      // header: {
      //   Accept: 'application/json',
      //   'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      // },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师详情
export const lawyerDetail = (ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawyerDetail.url + `/${ID}?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawyerDetail.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师文章列表
export const articleList = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.articleList.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.articleList.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师文章详情
export const articleDetail = (ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.articleDetail.url + `/${ID}?accessToken=${accessToken}`,
      method: api.lawyerSetup.articleDetail.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师专长
export const lawyerSpeciality = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawyerSpeciality.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawyerSpeciality.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师 发表文章
export const writeArticle = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.writeArticle.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.writeArticle.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师 律师函列表
export const lawOfficeList = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawOfficeList.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawOfficeList.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师 律师函详情
export const lawOfficeDetail = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawOfficeDetail.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawOfficeDetail.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师 我的账户信息
export const memberInfo = (ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.memberInfo.url + `/${ID}?accessToken=${accessToken}`,
      method: api.lawyerSetup.memberInfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//律师 服务记录
export const serviceLog = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawyerMoney.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawyerMoney.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//服务详情
export const serviceDetail = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.serveinfo.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.serveinfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//服务详情 点击完成
export const serveInfoComplete = (params, ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.serveinfoComplete.url + `/${ID}?accessToken=${accessToken}`,
      method: api.lawyerSetup.serveinfoComplete.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//服务详情 图文回复
export const serveInfoReply = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.serveinfoReply.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.serveinfoReply.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//服务详情 对律师进行评价
export const serveInfoLawyerScore = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.serveinfoLawyerScore.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.serveinfoLawyerScore.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
// 获取服务地区
export const getProvinces = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.getProvinces.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.getProvinces.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
// 提交 电话专问 、 图文专问 的接口
export const lawyerMoneyQuestions = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawyerMoneyQuestions.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawyerMoneyQuestions.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
// 修改律师信息
export const lawyerInfoAmend = (params, ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.lawyerSetup.lawyerInfoAmend.url + `?accessToken=${accessToken}`,
      method: api.lawyerSetup.lawyerInfoAmend.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}